<template>
  <FModal :loading="loading" header="编辑附件" width="900" ref="refFModal" @ok="flowDescChange">
    <FSection title="相关附件">
      <FUploader ref="refFUploader"/>
    </FSection>
  </FModal>
</template>
<script setup>
import FSection from '@/components/FSection/index.vue';
import FModal from '@/components/FModal/index.vue';
import {nextTick, shallowRef} from 'vue';
import FUploader from '@/components/FUploader/index.vue';

const loading = shallowRef(false);
const refFModal = shallowRef();
const refFUploader = shallowRef();
const refFlowDesc = shallowRef();
const emits = defineEmits(['flowDescChange']);
let flowDesc = {
  attachmentIds: undefined,
  additionalComments: undefined,
  formDefinitionId: undefined,
  formName: undefined,
};

function setData(flowDesc) {
  refFlowDesc.value = flowDesc;
  refFModal.value.open();
  nextTick(() => {
    refFUploader.value.setData(flowDesc.attachmentIds);
  });
}

function flowDescChange() {
  loading.value = true;
  emits('flowDescChange', refFUploader.value.getAttachmentIds());
}

defineExpose({
  setData
});
</script>
